package com.ymatou.promotion.api.testcase;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.promotion.api.parameter.AvailableCouponInfo;
import com.ymatou.promotion.api.parameter.CouponBatchBean;
import com.ymatou.promotion.api.parameter.ProductInfo;
import com.ymatou.promotion.api.parameter.ValidateCouponInfoBean;
import com.ymatou.promotion.api.service.ValidateCouponInfoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.database.model.YmtCoupon;
import com.ymttest.database.model.YmtCouponBatch;
import com.ymttest.database.model.YmtCouponPrivateUserBound;
import com.ymttest.database.model.YmtCouponScenario;
import com.ymttest.database.model.YmtCouponSetting;
import com.ymttest.database.model.YmtCouponValue;
import com.ymttest.database.sqlwapper.YmtCouponBatchWapper;
import com.ymttest.database.sqlwapper.YmtCouponPrivateUserBoundWapper;
import com.ymttest.database.sqlwapper.YmtCouponScenarioWapper;
import com.ymttest.database.sqlwapper.YmtCouponSettingWapper;
import com.ymttest.database.sqlwapper.YmtCouponValueWapper;
import com.ymttest.database.sqlwapper.YmtCouponWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.constant.ECode;

/**
 * 验证优惠券有效性
 * 
 * @author chenjiazhu
 * 
 *         备注： 1. 涉及商品优惠券有效性的等商品整合完成再添加 2. 涉及使用优惠券的，等使用优惠券的接口完成后再添加
 * 
 *         涉及存储过程：SP_CouponValidateScenario
 */
@TestSuite
public class Ts_ValidateCouponInfo {
    private static ValidateCouponInfoBean validatecouponinfoBean;
    private static ValidateCouponInfoCall validatecouponinfoCall;

    private static int buyerId;
    private static int sellerId;

    @BeforeClass
    public static void setUp() {
        Logger.createResultFile("验证优惠券有效性，并取得优惠券面值和使用方式接口");
    }

    @Before
    public void caseUp() {
        validatecouponinfoBean = new ValidateCouponInfoBean();
        validatecouponinfoCall = new ValidateCouponInfoCall();

        buyerId = Integer.parseInt(EnvSetup.getData("BuyUserId"));
        sellerId = Integer.parseInt(EnvSetup.getData("SellerId"));
    }

    @AfterClass
    public static void tearDown() {
        Logger.generateResult(validatecouponinfoCall.getOpurl());
    }

    @After
    public void caseDown() {
        Logger.end();
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_001() {
        Logger.start(true, "验证已领取的全场优惠券有效性");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }


    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    public void Tc_ValidateCouponInfo_002() {
        Logger.start(true, "验证已领取的商品优惠券有效性");
        try {

            setDefaultValidateRecieveCouponInfoBean(2, null);
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_003() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：10：M商品神器微信（M商品在C2C分享到微信成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "10");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_004() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：洋码头PC（M商品在M2C-PC成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "1");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_005() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：2：洋码头WAP（M商品在M2C-WAP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "2");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_006() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：3：洋码头APP（M商品在M2C-APP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "3");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_007() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：4：神器APP（C商品在C2C-APP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "4");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_008() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：5：神器WAP（C商品在C2C-WAP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "5");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_009() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：6:神器PC（C商品在C2C-PC成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "6");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_010() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：7：神器微信（C商品通过C2C分享到微信成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "7");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_011() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：M商品神器APP（M商品在C2C-APP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "8");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_012() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：9：M商品神器WAP（M商品在C2C-WAP成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "9");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }


    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_013() {
        Logger.start(true, "验证已领取全场优惠券有效性-平台：11：M商品微信（M商品在其它产品分享到微信成交）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "11");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_014() {
        Logger.start(true, "验证已领取全场优惠券有效性，平台：12：下单器PC（在PC使用下单器生成订单）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "12");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_015() {
        Logger.start(true, "验证已领取全场优惠券有效性，平台：13：M商品其他渠道下单");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "13");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_016() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：洋码头PC（M商品在M2C-PC成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "1");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_017() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：洋码头PC（M商品在M2C-PC成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "2");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_019() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：3：洋码头APP（M商品在M2C-APP成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "3");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_020() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：4：神器APP（C商品在C2C-APP成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "4");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_021() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：5：神器WAP（C商品在C2C-WAP成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "5");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_022() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：6:神器PC（C商品在C2C-PC成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "6");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_023() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：7：神器微信（C商品通过C2C分享到微信成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "7");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_024() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：M商品神器APP（M商品在C2C-APP成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "8");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_025() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：9：M商品神器WAP（M商品在C2C-WAP成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "9");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }


    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_026() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性-平台：11：M商品微信（M商品在其它产品分享到微信成交）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "11");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_027() {
        Logger.start(true, "验证 已作废 全场 优惠券有效性，平台：12：下单器PC（在PC使用下单器生成订单）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "12");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_028() {
        Logger.start(true, "验证 已作废 全场 商品优惠券有效性，平台：13：M商品其他渠道下单");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "13");
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_029() {
        Logger.start(false, "反例-优惠券码非空验证");
        try {

            validatecouponinfoBean.setOrderAmount(new BigDecimal(2));
            validatecouponinfoBean.setBuyerId(buyerId);
            validatecouponinfoBean.setSellerId(sellerId);
            validatecouponinfoBean.setPlatformType(1);

            validatecouponinfoBean.setBuyerOrderNum(1);
            validatecouponinfoBean.setUserLevel(1);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail1,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_030() {
        Logger.start(false, "反例-订单金额非空验证");
        try {
            String couponCode = new YmtCouponPrivateUserBoundWapper().selectTop1().getsCouponCode();

            validatecouponinfoBean.setCouponCode(couponCode);
            validatecouponinfoBean.setBuyerId(buyerId);
            validatecouponinfoBean.setSellerId(sellerId);

            validatecouponinfoBean.setBuyerOrderNum(1);
            validatecouponinfoBean.setUserLevel(1);

            List<ProductInfo> produnctInfos = new ArrayList<ProductInfo>();
            validatecouponinfoBean.setProductList(produnctInfos);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals("当前平台不能使用本券码",
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_031() {
        Logger.start(false, "反例-买家用户编号非空验证");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setSellerId(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail6,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_032() {
        Logger.start(false, "反例-卖家用户编号非空验证");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setBuyerId(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail4,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_033() {
        Logger.start(false, "反例-平台类型非空验证");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, "1");
            validatecouponinfoBean.setPlatformType(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail5,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    public void Tc_ValidateCouponInfo_034() {
        Logger.start(false, "反例-买家已购买成功的订单数量非空验证");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setOrderAmount(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.SUCCESS, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals("金额与优惠券使用条件不匹配",
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_035() {
        Logger.start(false, "反例-用户等级非空验证-默认值0");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setUserLevel(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_036() {
        Logger.start(false, "反例-订单产品列表信息非空验证");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setProductList(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.ERROR500, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail2,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_037() {
        Logger.start(false, "反例-验证场景：券码不存在");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            validatecouponinfoBean.setCouponCode(null);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail1,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_038() {
        Logger.start(false, "反例-验证场景：券码仅通过手机验证的用户可以使用");
        try {

            CouponCallService couponCallService = new CouponCallService();

            CouponBatchBean couponBatchBean = couponCallService.setCouponBatchBean(1, "1", 3, 1);
            String batchCode = couponCallService.createSellerCoupon(couponBatchBean).getBatchCode();

            String couponCode = couponCallService.receiveCouponInfo(batchCode, buyerId);

            YmtCouponBatch ymtCouponBatch = new YmtCouponBatchWapper().selectBysBatchCode(batchCode).get(0);
            new YmtCouponSettingWapper().setbIsMobileVerifyTrue(ymtCouponBatch.getiCouponSettingId());

            validatecouponinfoBean.setCouponCode(couponCode);
            validatecouponinfoBean.setOrderAmount(couponBatchBean.getCouponValues().get(0).getOrderValue());
            validatecouponinfoBean.setBuyerId(buyerId);
            validatecouponinfoBean.setSellerId(sellerId);
            validatecouponinfoBean.setPlatformType(1);
            // validatecouponinfoBean.setUserLoginMobileAccount("18621111111");

            List<ProductInfo> produnctInfos = new ArrayList<ProductInfo>();
            validatecouponinfoBean.setProductList(produnctInfos);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail7,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_039() {
        Logger.start(false, "反例-验证场景：券码不在有效期内（scenario.dValidStart.Date > DateTime.Today）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            String couponCode = validatecouponinfoBean.getCouponCode();

            Date dNow = new Date(); // 当前时间
            Date dNew = new Date();

            Calendar calendar1 = Calendar.getInstance(); // 得到日历
            calendar1.setTime(dNow);// 把当前时间赋给日历
            calendar1.add(Calendar.DAY_OF_MONTH, 1); // 设置为前一天
            dNew = calendar1.getTime(); // 得到前一天的时间

            if (!couponCode.equals(""))
                new YmtCouponWapper().setdValidStart(dNew, couponCode);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail8,
                    validatecouponinfoCall.getMsg(), "验证报错信息");


        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_040() {
        Logger.start(false, "反例-验证场景：券码不在有效期内（scenario.dValidEnd.Date < DateTime.Today）");
        try {

            setDefaultValidateRecieveCouponInfoBean(1, null);
            String couponCode = validatecouponinfoBean.getCouponCode();

            Date dNow = new Date(); // 当前时间
            Date dNew = new Date();

            Calendar calendar1 = Calendar.getInstance(); // 得到日历
            calendar1.setTime(dNow);// 把当前时间赋给日历
            calendar1.add(Calendar.DAY_OF_MONTH, -1); // 设置为前一天
            dNew = calendar1.getTime(); // 得到前一天的时间

            if (!couponCode.equals(""))
                new YmtCouponWapper().setdValidEnd(dNew, couponCode);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail8,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_041() {
        Logger.start(false, "反例-验证场景：券码使用次数已超过最大使用数");
        try {
            setDefaultValidateRecieveCouponInfoBean(1, null);

            int iCouponSettingId =
                    new YmtCouponWapper().selectBysCouponCode(validatecouponinfoBean.getCouponCode()).get(0)
                            .getiCouponSetting();
            new YmtCouponSettingWapper().setiMaxUseTime(iCouponSettingId, 0);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals("券码使用次数已超过最大使用数",
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 使用接口出来后添加
     */
    public void Tc_ValidateCouponInfo_042() {
        Logger.start(false, "反例-验证场景：券码使用次数已超过最大使用数(使用接口出来后添加)");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    /**
     * 场景：buyerOrderNum > 0 && scenario.iUserType == 1
     */
    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_043() {
        Logger.start(false, "反例-验证场景：当前用户不能使用本券码（检查优惠券适用会员类型 - 新用户）");
        try {
            setDefaultValidateInvalidCouponInfoBean(1, null);

            String couponCode = validatecouponinfoBean.getCouponCode();

            int iBatchId = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0).getiBatchId();
            int iCouponSettingId = new YmtCouponBatchWapper().selectByPrimaryKey(iBatchId).getiCouponSettingId();
            int icouponscenarioid =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(iCouponSettingId).get(0).getiScenarioId();

            new YmtCouponScenarioWapper().setiUserType(2, icouponscenarioid);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail9,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    /**
     * 场景：buyerOrderNum == 0 && scenario.iUserType != 1 && scenario.iUserType != 0
     */
    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_044() {
        Logger.start(false, "反例-验证场景：当前用户不能使用本券码（检查优惠券适用会员类型 - 老用户）");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, null);
            validatecouponinfoBean.setBuyerOrderNum(1);

            String couponCode = validatecouponinfoBean.getCouponCode();

            int iBatchId = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0).getiBatchId();
            int iCouponSettingId = new YmtCouponBatchWapper().selectByPrimaryKey(iBatchId).getiCouponSettingId();
            int icouponscenarioid =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(iCouponSettingId).get(0).getiScenarioId();

            new YmtCouponScenarioWapper().setiUserType(1, icouponscenarioid);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail9,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_018() {
        Logger.start(false, "反例-验证场景：当前平台不能使用本券码");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, "2");
            validatecouponinfoBean.setBuyerOrderNum(1);
            validatecouponinfoBean.setPlatformType(3);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail5,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_045() {
        Logger.start(false, "反例-验证场景：当前用户等级不能使用本券码");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, null);
            validatecouponinfoBean.setBuyerOrderNum(1);
            validatecouponinfoBean.setUserLevel(2);

            String couponCode = validatecouponinfoBean.getCouponCode();

            int iBatchId = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0).getiBatchId();
            int iCouponSettingId = new YmtCouponBatchWapper().selectByPrimaryKey(iBatchId).getiCouponSettingId();
            int icouponscenarioid =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(iCouponSettingId).get(0).getiScenarioId();

            new YmtCouponScenarioWapper().setsUserLevels("5,6", icouponscenarioid);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail10,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 等商品整合完再做
     */
    public void Tc_ValidateCouponInfo_046() {
        Logger.start(false, "反例-验证场景：券码指定卖家，与当前商品不匹配");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.ERROR500, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail2,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 等商品整合完再做
     */
    public void Tc_ValidateCouponInfo_047() {
        Logger.start(false, "反例-验证场景：券码指定活动，与当前商品不匹配");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.ERROR500, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail2,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 等商品整合完再做
     */
    public void Tc_ValidateCouponInfo_048() {
        Logger.start(false, "反例-验证场景：券码指定配送，与当前商品不匹配");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.ERROR500, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail2,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 等商品整合完再做
     */
    public void Tc_ValidateCouponInfo_049() {
        Logger.start(false, "反例-验证场景：券码指定类目，与当前商品不匹配");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();


        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    /**
     * 等商品整合完再做
     */
    public void Tc_ValidateCouponInfo_050() {
        Logger.start(false, "反例-验证场景：券码指定品牌，与当前商品不匹配");
        try {

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.ERROR500, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Fail2,
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_051() {
        Logger.start(false, "反例-验证场景：券码指定商品，与当前商品不匹配");
        try {

            CouponCallService couponCallService = new CouponCallService();

            // 创建优惠券批次
            CouponBatchBean couponBatchBean = couponCallService.setCouponBatchBean(1, "1", 10, 1);
            String batchCode = couponCallService.createSellerCoupon(couponBatchBean).getBatchCode();

            // 用户领取优惠券
            String couponCode = couponCallService.receiveCouponInfo(batchCode, buyerId);

            // setBean
            validatecouponinfoBean.setCouponCode(couponCode);
            validatecouponinfoBean.setOrderAmount(couponBatchBean.getCouponValues().get(0).getOrderValue());
            validatecouponinfoBean.setBuyerId(buyerId);
            validatecouponinfoBean.setSellerId(sellerId);

            validatecouponinfoBean.setPlatformType(1);

            validatecouponinfoBean.setBuyerOrderNum(0);
            validatecouponinfoBean.setUserLevel(0);

            List<ProductInfo> productInfoList = new ArrayList<ProductInfo>();

            ProductInfo productInfo = new ProductInfo();

            productInfo.setActivityId(0);
            productInfo.setBrandId(2111);
            productInfo.setCategoryId(3111);
            productInfo.setProductId("12334556");
            productInfo.setProductQty(1);
            productInfo.setProductPrice(new BigDecimal(1000));

            productInfoList.add(productInfo);

            String productIds = "345555";
            couponCallService.ChangeSellerCoupon(batchCode, productIds);

            validatecouponinfoBean.setProductList(productInfoList);
            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            Logger.verifyEquals(ECode.FAILED201, validatecouponinfoCall.getCode(),
                    "验证返回code");
            Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                    "验证返回Bcode");
            Logger.verifyEquals("券码指定商品，与当前商品不匹配",
                    validatecouponinfoCall.getMsg(), "验证报错信息");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_ValidateCouponInfo_052() {
        Logger.start(false, "正例-验证场景：验证用户等级检查");
        try {

            setDefaultValidateInvalidCouponInfoBean(1, null);
            validatecouponinfoBean.setBuyerOrderNum(1);
            validatecouponinfoBean.setUserLevel(5);

            String couponCode = validatecouponinfoBean.getCouponCode();

            int iBatchId = new YmtCouponWapper().selectBysCouponCode(couponCode).get(0).getiBatchId();
            int iCouponSettingId = new YmtCouponBatchWapper().selectByPrimaryKey(iBatchId).getiCouponSettingId();
            int icouponscenarioid =
                    new YmtCouponSettingWapper().selectByiCouponSettingId(iCouponSettingId).get(0).getiScenarioId();

            new YmtCouponScenarioWapper().setsUserLevels("5,6", icouponscenarioid);

            validatecouponinfoCall.setData(validatecouponinfoBean);
            validatecouponinfoCall.callService();

            verifyReturn(1);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    /**
     * 设置 默认 已领取 全场 优惠券bean
     * 
     * @param scenarioType
     * @param usePlatforms
     * @throws ClientProtocolException
     * @throws IOException
     */
    private void setDefaultValidateRecieveCouponInfoBean(Integer scenarioType, String usePlatforms)
            throws ClientProtocolException, IOException
    {
        CouponCallService couponCallService = new CouponCallService();

        // 创建优惠券批次
        CouponBatchBean couponBatchBean = couponCallService.setCouponBatchBean(scenarioType, usePlatforms, 10, 1);
        String batchCode = couponCallService.createSellerCoupon(couponBatchBean).getBatchCode();

        // 用户领取优惠券
        String couponCode = couponCallService.receiveCouponInfo(batchCode, buyerId);

        // setBean
        validatecouponinfoBean.setCouponCode(couponCode);
        validatecouponinfoBean.setOrderAmount(couponBatchBean.getCouponValues().get(0).getOrderValue());
        validatecouponinfoBean.setBuyerId(buyerId);
        validatecouponinfoBean.setSellerId(sellerId);

        if (usePlatforms != null)
            validatecouponinfoBean.setPlatformType(Integer.parseInt(usePlatforms));
        else {
            validatecouponinfoBean.setPlatformType(1);
        }

        validatecouponinfoBean.setBuyerOrderNum(0);
        validatecouponinfoBean.setUserLevel(0);

        List<ProductInfo> productInfoList = new ArrayList<ProductInfo>();
        validatecouponinfoBean.setProductList(productInfoList);
    }

    /**
     * 设置 默认 已作废 全场 优惠券bean
     * 
     * @param usePlatforms
     * @throws ClientProtocolException
     * @throws IOException
     */
    private void setDefaultValidateInvalidCouponInfoBean(int scenarioType, String usePlatforms)
            throws ClientProtocolException, IOException
    {
        CouponCallService couponCallService = new CouponCallService();

        // 创建优惠券批次
        CouponBatchBean couponBatchBean = couponCallService.setCouponBatchBean(scenarioType, usePlatforms, 10, 1);
        String batchCode = couponCallService.createSellerCoupon(couponBatchBean).getBatchCode();

        // 用户领取优惠券
        String couponCode = couponCallService.receiveCouponInfo(batchCode, buyerId);

        // 作废优惠券
        couponCallService.inValidCoupon(batchCode);

        // setBean
        validatecouponinfoBean.setCouponCode(couponCode);
        validatecouponinfoBean.setOrderAmount(couponBatchBean.getCouponValues().get(0).getOrderValue());
        validatecouponinfoBean.setBuyerId(buyerId);
        validatecouponinfoBean.setSellerId(sellerId);

        if (usePlatforms != null)
            validatecouponinfoBean.setPlatformType(Integer.parseInt(usePlatforms));
        else {
            validatecouponinfoBean.setPlatformType(1);
        }

        validatecouponinfoBean.setBuyerOrderNum(0);
        validatecouponinfoBean.setUserLevel(0);

        List<ProductInfo> productInfoList = new ArrayList<ProductInfo>();
        validatecouponinfoBean.setProductList(productInfoList);
    }


    private void verifyReturn(int CouponState)
    {
        Logger.verifyEquals(ECode.SUCCESS, validatecouponinfoCall.getCode(),
                "验证返回code");
        Logger.verifyEquals(ECode.BCODE0, validatecouponinfoCall.getBCode(),
                "验证返回Bcode");
        Logger.verifyEquals(ECode.COUPON_ValidateRecieveCouponInfo_Success,
                validatecouponinfoCall.getMessageText(), "券码验证通过");

        AvailableCouponInfo availableCouponInfo = validatecouponinfoCall
                .getAvailableCouponInfo();

        YmtCoupon coupon = new YmtCouponWapper().selectBysCouponCode(
                availableCouponInfo.getCouponCode()).get(0);
        YmtCouponPrivateUserBound couponPrivateUserBound = new YmtCouponPrivateUserBoundWapper()
                .selectBysCouponCode(availableCouponInfo.getCouponCode())
                .get(0);
        YmtCouponBatch couponBatch = new YmtCouponBatchWapper()
                .selectByPrimaryKey(coupon.getiBatchId());
        YmtCouponValue couponValue = new YmtCouponValueWapper()
                .selectByiCouponSettingId(couponBatch.getiCouponSettingId())
                .get(0);
        YmtCouponSetting couponSetting = new YmtCouponSettingWapper()
                .selectByiCouponSettingId(couponBatch.getiCouponSettingId())
                .get(0);
        YmtCouponScenario couponScenario = new YmtCouponScenarioWapper()
                .selectByiCouponScenarioId(couponSetting.getiScenarioId()).get(
                        0);

        // 验证返回CouponCode
        Logger.verifyEquals(validatecouponinfoBean.getCouponCode(),
                availableCouponInfo.getCouponCode(), "验证返回CouponCode与请求中一致");

        // 验证返回 BatchCode
        Logger.verifyEquals(couponBatch.getsBatchCode(),
                availableCouponInfo.getBatchCode(),
                "验证BatchCode与数据库表couponBatch中sBatchCode一致");

        // 验证返回 MinOrderAmount
        Logger.verifyEquals(0,
                availableCouponInfo.getMinOrderAmount().compareTo(couponValue.getFminordervalue()),
                "验证返回MinOrderAmount与数据库表couponValue中Fminordervalue一致");

        // 验证返回 CouponValue
        Logger.verifyEquals(0,
                availableCouponInfo.getCouponValue().compareTo(couponValue.getFcouponvalue()),
                "验证返回CouponValue与数据库表ymt_couponValue中字段Fcouponvalue一致");

        // 验证返回 CouponType
        Logger.verifyEquals(2,
                availableCouponInfo.getCouponType(),
                "验证返回CouponType与数据库表ymt_couponValue中字段CouponType中一致");

        // 验证返回 CouponUseType
        Logger.verifyEquals(couponSetting.getiCouponUseType(),
                Integer.parseInt(availableCouponInfo.getCouponUseType()),
                "验证返回CouponUseType与数据库表ymt_couponValue中字段CouponUseType中一致");

        // 验证返回 PlatformType
        // if(availableCouponInfo.getPlatformType()!=0 || couponScenario.getSuseplatforms()!=null)
        // {
        // Logger.verifyEquals(couponScenario.getSuseplatforms(),
        // availableCouponInfo.getPlatformType(),
        // "验证返回PlatformType与数据库中一致,接口没有返回数据，需要修复");
        // }

        SimpleDateFormat formatter = new SimpleDateFormat(
                "yyyy-MM-dd HH:mm:ss");

        // 验证返回 ValidBegin
        Logger.verifyEquals(getDate(coupon.getdValidStart()),
                availableCouponInfo.getValidBegin(),
                "验证返回ValidBegin与数据库表Ymt_coupon中字段dValidStart一致");

        // 验证返回 ValidEnd
        Logger.verifyEquals(getDate(coupon.getdValidEnd()),
                availableCouponInfo.getValidEnd(),
                "验证返回ValidEnd与数据库表Ymt_coupon中字段dValidEnd中一致");

        // 验证返回 Remainder
        Logger.verifyEquals(1,
                availableCouponInfo.getRemainder(),
                "验证返回Remainder正确");

        // 验证返回 CouponState
        Logger.verifyEquals(CouponState,
                availableCouponInfo.getCouponState(),
                "验证返回CouponState正确");

        // // 验证返回 UserId
        // Logger.verifyEquals(buyerId,
        // availableCouponInfo.getUserId(),
        // "验证返回UserId与数据库中一致,接口没有返回数据，需要修复");
        //
        // // 验证返回 UserName
        // Logger.verifyEquals(EnvSetup.getData("BuyUserName"),
        // availableCouponInfo.getUserName(),
        // "验证返回UserName与数据库中一致,接口没有返回数据，需要修复");

        // 验证返回 CreateType
        Logger.verifyEquals(2,
                availableCouponInfo.getCreateType(),
                "验证返回CreateType正确");

    }

    private String getDate(Date date)
    {
        SimpleDateFormat formatter1 = new SimpleDateFormat(
                "yyyy-MM-dd");
        SimpleDateFormat formatter2 = new SimpleDateFormat(
                "HH:mm:ss");

        return formatter1.format(date) + "T" + formatter2.format(date);
    }
}
